// import { send_msg as url } from './config';
import set from '@dfeidao/atom-web/local/set';
import get from '@dfeidao/atom-web/storage/get';

import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import { IFeidaoAiBrowserComponent } from '@dfeidao/web/interfaces';
// import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import hide_loading from '../../atom/hide-loading';
import show_loading from '../../atom/show-loading';

import P01 from './P01';
import P04 from './P04';
import P05 from './P05';

export default async function a000(fd: IFeidaoAiBrowserComponent, role_no: string, role_type_id: string) {
	//  调用事件
	fd.data.node.querySelector<HTMLDivElement>('[id="zjs"]').classList.remove('display-n');
	// debugger;

	const productid1 = get('productid');
	// console.log(productid1);

	// console.log(args)

	// console.log(productid);
	set(fd, 'role_no', role_no);
	set(fd, 'productid', productid1);

	set(fd, 'role', {
		role_no, role_type_id
	});
	set(fd, 'page_no', 1);
	set(fd, 'page_size', 5);
	set(fd, 'role_type_id', role_type_id);
	const page_no = 1;
	const page_size = 5;
	show_loading();
	const res = await nodejs<{ dataArray: object[], count: number, page_no: number, page_size: number }>('roler/zj-000004/s001', { productid: productid1, role_no, page_no, page_size });
	hide_loading();
	if (res.count === 0) {
		render(fd, '', P01, 'P01', 'inner');
		fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="P05"]').innerHTML = '';
		render(fd, '', P04, 'P04', 'inner');
	} else {
		render(fd, res.dataArray, P01, 'P01', 'inner');
		res.page_no = page_no;
		res.page_size = page_size;
		fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="P04"]').innerHTML = '';

		// if (res.count > page_size) {
		render(fd, res, P05, 'P05', 'inner');
		// } else {
		// 	fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="P05"]').innerHTML = '';
		// }
	}
}
